#ifndef PEAKFILEGENERATORTHREAD_H
#define PEAKFILEGENERATORTHREAD_H
//
#include <QThread>
#include <QMutex>
#include "datafile.h"
//
class PeakFileGeneratorThread : public QThread
{
Q_OBJECT

public:
	PeakFileGeneratorThread( QFile * file, QFile * pkfile, qint64 samplPerChan, int chans, int samplPerBlock, QDataStream::ByteOrder byteOrder, DataFile::DataTypes dataType );
	~PeakFileGeneratorThread();

public slots:
	void cancel();

signals:
	void progress( int percent );
	
protected:
	void run();

private:
	template <class T> int generatorLoop();

	QMutex mutex;
	bool abort;
	QFile * mainfile;
	QFile * peakfile;
	qint64 samples;
	int channels;
	int blocksize;
	QDataStream::ByteOrder byteorder;
	DataFile::DataTypes datatype;
};

#endif
